<?php
uses('slideshow');
class SlidesController extends AppController
{
    var $name = 'Slides';
    var $scaffold;
    
    var $helpers = array('Slideshow','Javascript', 'Ajax');
    var $components = array('Slideshow');
    
    /**
     * This method starts a slideshow for this active feed
     *
     * @param int $id ID of the feed
     * @param int $page pagenumber
     */
    function slideshow($feed = 1, $page = 1)
    {
		$mypaging = new Slideshow;
		
		// the chosen slide is searched here
		$data = $mypaging->findAll( $this->{$this->modelClass}, 
		                            array('order'=>'order', 
		                                  'limit'=>1, 
		                                  'page'=>$page,
		                                  'feed'=>$feed, 
		                                  'criteria'=>'WHERE `feed_id` ='.$feed.'
                                                         AND `visible` = true
                                                         AND `show_from` <= CURRENT_TIMESTAMP()
                                                         AND `show_till` > CURRENT_TIMESTAMP()')
		                          );
		$this->set('slides', $data);
		$this->set('mypaging', $mypaging);
		//print_r($this);
		$this->autoLayout=0; // disables the header/footer of the page
		
    }
    
    /**
     * Get the slide of the specified id
     *
     * @param int $id
     */
    function view($id = null)
    {
	        $this->Slide->id = $id;
	        $this->set('slide', $this->Slide->read());
    }


}

?>